<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../base_top.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>关注的商品</title>
    <%@ include file="../base_head.jsp" %>
	
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/user/common.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/user/style.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/user/att_style.css">
    <link rel="stylesheet" href="<%=basePath%>css/goods/kkpager_blue.css">
    <script type="text/javascript" src="<%=basePath%>js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/user/zs.order.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    	//单个取消关注
    	$(".cheal").click(function() {
        	var conf = confirm('确定取消关注吗？');
        	var btn = $(this);
        	var id = btn.attr("id");
        	if (conf) {
        		$.ajax({
    				cache: false,
    				url:"collect/collectGoodsCancel",
    				type: "GET",
    				data: {ids:id},
    				dataType:"json",
    			    success: function(data) {
    			    	if (data == "success") {
    			    		btn.parent().parent().remove();
    			    	}
    			    }
    			});
        	};
        });
    	
    	//批量取消关注
    	$(".cancel_attention").click(function() {
    		var conf = confirm('确定取消关注吗？');
    		if (existsChecked() && conf) {
    			var checkArray = new Array();
    			var url = "collect/collectGoodsCancel?";
    			var i = 0;
    			$(".att_con_check").each(function() {
    				if ($(this).is(':checked')) {
    					checkArray.push($(this));
    					if (i == 0) {
	    					url += "ids=" + $(this).val();
	    					i++;
    					} else {
    						url += "&ids=" + $(this).val();
    					}
    				}
    			});
    			
    			$.ajax({
    				cache: false,
    				url: url,
    				type: "GET",
    				data: new Date().getTime(),
    				dataType:"json",
    			    success: function(data) {
    			    	if (data == "success") {
    			    		for (var i = 0; i<checkArray.length; i++) {
    			    			checkArray[i].parent().parent().remove();
    			    		}
    			    	}
    			    }
    			});
    		}
    	});
    	
    	//批量加入购物车
    	$(".add_shopcart").click(function() {
    		var conf = confirm('确定加入购物车吗？');
    		if (conf) {
    			var url = "shopcart/addShopCart";
    			var i = 0;
    			$(".att_con_check").each(function() {
    				if ($(this).is(':checked')) {
	    				var goodsNum = $(this).parent().parent().find("input[name=goodsNum]").val();
	    				if (i == 0) {
	    					url += "?goodsNum=" + goodsNum;
	    					i++;
	    				} else {
	    					url += "&goodsNum=" + goodsNum;
	    				}
    				}
    			});
    			window.location.href= url;
    		}
    	});
    	
    	//全选
    	$(".all_checked").click(function() {
    		var check = $(this).is(':checked');
    		$(".all_checked").each(function() {
    			$(this).prop("checked",check);
    		});
    		if(check) {
    			$(".att_con_check").each(function() {
    				$(this).prop("checked",true);
    			});
    		} else {
    			$(".att_con_check").each(function() {
    				$(this).prop("checked",false);
    			});
    		}
    	});
    	
    	function existsChecked() {
        	var exists = false;
    		$(".att_con_check").each(function() {
    			if($(this).is(':checked')) {
    				exists = true;
    			}
    		});
    		return exists;
    	}
    	
    	var totalPage = $("input[name='totalPage']").val();
        var totalRecords = $("input[name='totalRecords']").val();
        var pageNo = $("input[name='pageNo']").val();
        if (!pageNo) {pageNo = 1;}
        paper(totalPage, totalRecords, pageNo, "collect/collectGoodsList", "");
    });
    </script>
  </head>
  
  <body>
<!--topbar开始-->
<%@ include file="../page_topbar.html" %>
<!--topbar结束-->
<div id="wrap">
    <!--search开始-->
    <%@ include file="../selfCenter_search.html" %>
    <!--search结束-->
    
    <!--左边订单中心开始-->
    <%@ include file="../selfCenter_menu.html" %>
    <!--左边订单中心结束-->
    
    <!--右边关注的商品开始-->
        <div class="common_guanzhu">
          	<div class="common_guanzhu_title">关注的商品
          		<div style="width: 80px;  border: 1px solid #A60000;"></div>
          	</div>
	        <div class="common_guanzhu_title_sub"><a href="collect/collectStoreList">关注的店铺</a></div>
	        <div class="common_guanzhu_title_sub"><a href="JavaScript:void(0);">关注的活动</a></div>
        </div>
        <!--商品详情开始-->
        <div class="att_shopping">
            <div class="att_shopping_title">
                <input type="checkbox" class="all_checked">全选
                <a href="JavaScript:void(0);" class="add_shopcart">加入购物车&nbsp;&nbsp;|</a>
                <a href="JavaScript:void(0);" class="cancel_attention">取消关注</a>
            </div>
            <div class="tuijian_ad_main">
	            <s:iterator value="#request.collects" id="collect">
	            <div class="tuijian_ad_mainad">
	            	<input type="hidden" value='<s:property value="#request.collect.goodsNum"/>' name="goodsNum"/>
                    <div class="img">
                        <a href='goods/goodsDetail?id=<s:property value="#request.collect.goodsNum"/>' target="_blank"><img src='<s:property value="#request.collect.mainpic"/>'></a>
                    </div>
                    <div class="content"><input name="ids" type="checkbox" class="att_con_check" value='<s:property value="#request.collect.id"/>'><s:property value="#request.collect.goodsName"/></div>
                    <div class="price">￥<s:property value="#request.collect.goodsPrice"/></div>
                    <div class="att_btn">
	                    <input type="button" value="加入购物车" class="add" onclick="window.location.href='shopcart/addShopCart?goodsNum=<s:property value="#request.collect.goodsNum"/>'">
	                    <input type="button" value="取消" class="cheal" id='<s:property value="#request.collect.id"/>'>
                    </div>
               	</div>
	            </s:iterator>
            </div>
            <div class="att_shopping_foot">
                <div class="att_shopping_foot_title">
                    <input type="checkbox" class="all_checked">全选
                    <a href="JavaScript:void(0);" class="add_shopcart">加入购物车&nbsp;&nbsp;|</a>
                	<a href="JavaScript:void(0);" class="cancel_attention">取消关注</a>
                </div>
                <div class="att_shopping_foot_right">
                <input type="hidden" name="pageNo" value="${pageNo}"/>
		    	<input type="hidden" name="totalPage" value="${totalPage}"/>
		    	<input type="hidden" name="totalRecords" value="${totalRecords}"/>
		        <div id="kkpager"></div>
                </div>
            </div>
        </div>
        <!--商品详情结束-->
        <!--为你推荐开始-->
		  <div class="att_tuijian">
		      <div class="att_tuijian_title">为你推荐</div>
		      <%@ include file="../selfCenter_rec-you-goods.html" %>
		 </div>
		 <!--为你推荐结束-->
    <!--右边关注的商品结束-->
    <!--广告-->
    <%@ include file="../selfCenter_bottom_four-ad.html" %>
    <!--广告结束-->

</div>

</body>
</html>
